<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // Array、Set有:
        // keys() ：返回键名的遍历器
        // values() ：返回键值的遍历器
        // entries() ：返回键值对的遍历器
        // forEach() ：使用回调函数遍历每个成员
        var nums=["aa","bb","cc","dd"];
        var it=nums.keys();//获取所有的索引的迭代器
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        var next=it.next();
        while(!next.done){
            console.log(next.value);//0
            next=it.next();

        }

        console.log("==================");
        var it=nums.values();//获取所有值的迭代器
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        // console.log(it.next());
        var next=it.next();//对象
        while(!next.done){
            console.log(next.value);
            next=it.next();
        }
        console.log("--------------");
        var it=nums.entries();//获取所有索引和值的迭代器
        console.log(it.next());
        console.log(it.next());
        console.log(it.next());
        console.log(it.next());
        console.log(it.next()); 
        console.log("*******************");
        //set结构没有键名，只有键值(或者键名和键值是同一个值)
        var set=new Set(["a","b","c","d","a","b"]);
        var its=set.keys();
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log("============");
        var its=set.values();
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log("#################");
        var its=set.entries();
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log(its.next());
        console.log("##################");
        nums.forEach(function(value,index){
            console.log(value,index);//元素值  索引
        });
        set.forEach(function(value,index){
            console.log(value,index);
        });


    </script>
</head>
<body>
    
</body>
</html>